
<?php
/**
 * Created by PhpStorm.
 * User: Wenda Fang
 * Date: 14-1-4
 * Time: 下午1:06
 * Desc: This is the entry of the website
 */
    include('header.php');
    $siteinfo = $mysqli->get_siteinfo($categoryId);
?>


<div class="container overview">
    <?php
    $i = 0;
    //format the site info to output
    while($row = $siteinfo->fetch_row()) {
        if ($i % 3 == 0) {
            echo('<div class="row">');
        }
    ?>
            <div class="col-lg-4">
              <a href="javascript:void(0)"  onclick="tolink('<?php echo($row[3]); ?>','<?php echo($row[0]); ?>')"  target="_blank">
                  <img src="<?php echo($row[4]);?>" alt="<?php echo($row[1]); ?>">
              </a>
              <h2>
                  <a href="javascript:void(0)"  onclick="tolink('<?php echo($row[3]); ?>','<?php echo($row[0]); ?>')" target="_blank">
                      <?php echo($row[1]); ?>
                  </a>
              </h2>
              <p><?php echo($row[2]); ?></p>
            </div>

    <?php
        if ($i % 3 == 2) {
            echo('</div>');
        }
        $i++;
    }
    $siteinfo->close();
    $mysqli->close();
    ?>
</div>

<script>
    function tolink(url,id){
        $.get("addClick.php", { 'id': id },
            function(data){
                if (data == 1) {
                    window.location.href = url;
                }
            });
    };
</script>
<?php
    include('footer.php');
?>